This is an R Markdown document. Markdown is a simple formatting syntax for authoring HTML, PDF, and MS Word documents. For more details on using R Markdown see http://rmarkdown.rstudio.com.
When you click the Knit button a document will be generated that includes both content as well as the output of any embedded R code chunks within the document. You can embed an R code chunk like this:
summary(cars)
## speed dist
## Min. : 4.0 Min. : 2.00
## 1st Qu.:12.0 1st Qu.: 26.00
## Median :15.0 Median : 36.00
## Mean :15.4 Mean : 42.98
## 3rd Qu.:19.0 3rd Qu.: 56.00
## Max. :25.0 Max. :120.00
You can also embed plots, for example:
Note that the echo = FALSE parameter was added to the
code chunk to prevent printing of the R code that generated the
plot.
Markdown and RMarkdown
Markdown is a way to make fancy documents. Make sure you “Knit” often – after every major change – to mitigate errors. Hashtags are how we make section levels of a doc.
This is bold. (that’s double asterisks). Or
italics. Or code.
To add a hyperlink, do [link text](url) without
backticks.
For example, go here
To link to sections of your document, do
[link text](#section-name), without backticks, with hyphens
for spaces, and everything lower-cased. For example, go here.
To add more vertical space between blocks of text, use this: “ ” without quotes.
Should be more space now.
To include an image – fun! first put an image inside
the folder where your Rmd file is located. Then type
{width="50%"}

RMarkdown is just Markdown with
R code woven in.
You can R stuff in the same line as text. For example, 6 will show as 6. (It would like backtick lower-case-r space then code then backtick).
You can also do a full-multi-line CHUNK of R stuff:
# ```{r}
3 + 3
## [1] 6
# ```
Settings to control how R chunks appear:
eval = TRUE: which actually runs the code; if
FALSE, it shows the code but doesn’t run it.
echo = TRUE: which shows the code; if
FALSE, the code can run without being seen.
warnings = FALSE: which will turn off
warnings.
fig.cap = "figure caption" adds a figure
caption.
fig.width = 7 example of figure width.
fig.height = 4 example of figure width. height?
-Max
library(readr)
energy<-read_csv("../data/IRENA data.csv", skip=1)
## Rows: 67200 Columns: 6
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (5): Country/area, Technology, Data Type, Grid connection, Electricity s...
## dbl (1): Year
##
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
energy%>% names
## [1] "Country/area" "Technology" "Data Type"
## [4] "Grid connection" "Year" "Electricity statistics"
energy%>% head
## # A tibble: 6 × 6
## `Country/area` Technology `Data Type` `Grid connection` Year
## <chr> <chr> <chr> <chr> <dbl>
## 1 Afghanistan Total renewable Electricity Generation… On-grid 2000
## 2 Afghanistan Total renewable Electricity Generation… On-grid 2001
## 3 Afghanistan Total renewable Electricity Generation… On-grid 2002
## 4 Afghanistan Total renewable Electricity Generation… On-grid 2003
## 5 Afghanistan Total renewable Electricity Generation… On-grid 2004
## 6 Afghanistan Total renewable Electricity Generation… On-grid 2005
## # ℹ 1 more variable: `Electricity statistics` <chr>
energy%>% tail
## # A tibble: 6 × 6
## `Country/area` Technology `Data Type` `Grid connection` Year
## <chr> <chr> <chr> <chr> <dbl>
## 1 Zimbabwe Nuclear Electricity Generation (GWh) On-grid 2019
## 2 Zimbabwe Nuclear Electricity Generation (GWh) On-grid 2020
## 3 Zimbabwe Nuclear Electricity Generation (GWh) On-grid 2021
## 4 Zimbabwe Nuclear Electricity Generation (GWh) On-grid 2022
## 5 Zimbabwe Nuclear Electricity Generation (GWh) On-grid 2023
## 6 Zimbabwe Nuclear Electricity Generation (GWh) On-grid 2024
## # ℹ 1 more variable: `Electricity statistics` <chr>
energy%>%pull(Technology)%>%unique%>%sort
## [1] "Biogas" "Coal and peat" "Geothermal energy"
## [4] "Natural gas" "Nuclear" "Offshore wind energy"
## [7] "Oil" "Onshore wind energy" "Renewable hydropower"
## [10] "Solar photovoltaic" "Total non-renewable" "Total renewable"
#filter data
fenergy<-energy%>%
filter(`Country/area`=='United States of America (the)')
library(ggplot2)
library(plotly)
##
## Attaching package: 'plotly'
## The following object is masked from 'package:ggplot2':
##
## last_plot
## The following object is masked from 'package:stats':
##
## filter
## The following object is masked from 'package:graphics':
##
## layout
p<-ggplot(fenergy,
aes(x=Year,
y=as.numeric(`Electricity statistics`),
fill=Technology))+
geom_area()
ggplotly(p)
## Warning in FUN(X[[i]], ...): NAs introduced by coercion
## Warning: Removed 26 rows containing non-finite outside the scale range
## (`stat_align()`).
#THIS IS A TEST CHANGE